package com.yss.netty.protocol;

import com.yss.netty.util.Constants;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;

public class Pong {

    public static ByteBuf pong() {
        byte[] msgBytes = Constants.PONG.getBytes();

        ByteBuf buf = Unpooled.buffer();
        buf.writeByte(Constants.MAGIC);
        buf.writeByte(Constants.VERSION);
        buf.writeLong(0L);
        buf.writeByte(0);
        buf.writeByte(CommandType.PONG.ordinal());
        buf.writeInt(msgBytes.length);
        buf.writeBytes(msgBytes);

        return buf;
    }

}
